Skip to content

Conversation

@andylinpersonal
Copy link

@andylinpersonal andylinpersonal commented Dec 15, 2025

When the divmod_s32s32_unsafe and divmod_u32u32_unsafe
is called without enabled PICO_DIVIDER_DISABLE_INTERRUPTS,
ldr r2, =SIO_BASE will be bypassed. Later access to SIO_DIV
will crash.

Fixes #2773

@andylinpersonal andylinpersonal changed the title Uninitialized r2 in divmod_u32u32_unsafe and divmod_s32s32_unsafe Fix uninit r2 in divmod_u32u32_unsafe and divmod_s32s32_unsafe Dec 16, 2025
  When the ``divmod_s32s32_unsafe`` and ``divmod_u32u32_unsafe``
is called without enabled ``PICO_DIVIDER_DISABLE_INTERRUPTS``,
``ldr r2, =SIO_BASE`` will be bypassed. Later access to ``SIO_DIV``
will crash.

Fixes raspberrypi#2773

Signed-off-by: Andy Lin <[email protected]>
@kilograham
Copy link
Contributor

good spot; i think i'd probably want to extract the unsafe variants into their own code/section (I doubt they are that ocmmonly used) to avoid the extra 2 cycles in the common divide code path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uninitialized r2 in divmod_x32x32_unsafe without PICO_DIVIDER_DISABLE_INTERRUPTS

2 participants